﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;
using NUnit.Framework;

namespace SmartStringResources.Tests
{
	public abstract class ACodeFileLockedBySourceControl : AResourceFileInCSharpEnvironment
	{
		[TestFixture]
		public class WhenCodeFileIsUnderSCC : ACodeFileLockedBySourceControl
		{
			protected override void Context()
			{
				base.Context();

				_autoMoqer.GetMock<DTE>()
					.Setup(dte => dte.SourceControl.IsItemUnderSCC(CodeFileName))
					.Returns(true);
			}

			protected override void BecauseOf()
			{
				SmartStringResourcesGenerator.Generate(_host, _templateFileName, _fileSystemService);
			}

			[Test]
			public void ShouldCheckIfFileIsCheckedout()
			{
				_autoMoqer.GetMock<DTE>()
					.Verify(dte => dte.SourceControl.IsItemCheckedOut(CodeFileName));
			}

			[TestFixture]
			public class WhenCodeFileIsNotCheckedOut : WhenCodeFileIsUnderSCC
			{
				protected override void Context()
				{
					base.Context();

					_autoMoqer.GetMock<DTE>()
						.Setup(dte => dte.SourceControl.IsItemCheckedOut(CodeFileName))
						.Returns(false);
				}

				protected override void BecauseOf()
				{
					SmartStringResourcesGenerator.Generate(_host, _templateFileName, _fileSystemService);
				}

				[Test]
				public void ShouldCheckoutFile()
				{
					_autoMoqer.GetMock<DTE>()
						.Verify(dte => dte.SourceControl.CheckOutItem(CodeFileName));
				}
			}
		}
	}
}
